﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace SlidePhoto
{
    public partial class MainFormCreator : Form
    {
        private List<string> pictures = new List<string>();

        public MainFormCreator()
        {
            InitializeComponent();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            openFileDialog.Filter = "Bilder (*.jpg, *.bmp, *.gif)|*.jpg;*.bmp;*.gif";
            openFileDialog.FilterIndex = 1;
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            saveFileDialog.Filter = "SlidePhoto slide show (*.spss)|*.spss";
            saveFileDialog.FilterIndex = 1;
        }

        private void selectPicturesButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (string fileName in openFileDialog.FileNames)
                {
                    pictures.Add(fileName);
                }
            }
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                StringBuilder SB = new StringBuilder();
                SB.Append(titleBox.Text + ";");
                SB.Append(personalMessageBox.Text + ";");

                foreach (string picture in pictures)
                {
                    SB.Append(picture + ";");
                }

                File.WriteAllText(saveFileDialog.FileName, Cryptography.Encrypt(SB.ToString(), "1a2523da8bfb4aa49586449b36ed3a14"));
                MessageBox.Show("Sie haben erfolgreich die Show gespeichert. Sicherstellen, dass die Fotos nicht verschoben oder gelöscht werden.");
                Application.Exit();
            }
        }
    }
}
